#include "DirScanner.h"

// 遍历给定的目录,参数为目标目录路径
void DirScanner::traverse(string &dir) {
    DIR *pDir = opendir(dir.c_str());
    if (!pDir) {
        perror("opdir");
        return;
    }

    struct dirent *ptr;
    while ((ptr = readdir(pDir)) != 0) {
        if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0) {
            _files.push_back(dir + "/" + ptr->d_name);
        }
    }
    closedir(pDir);
}

vector<string> &DirScanner::getFiles() {
    return _files;
}